package com.fpt.edu.vn.h2tv.dao.entity;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * TbOrder entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_order", catalog = "bookdb")
public class TbOrder implements java.io.Serializable {

	// Fields

	private Long orderid;
	private TbAccount tbAccount;
	private String receiveaddress;
	private String receivephonenumber;
	private Timestamp orderdate;
	private String receivepersonname;
	private Short shippingmethodid;
	private Short paymentmethodid;
	private Double totalprice;
	private Integer status;
	private List<TbOrderDetail> tbOrderDetails = new ArrayList<TbOrderDetail>(0);

	// Constructors

	/** default constructor */
	public TbOrder() {
	}

	/** minimal constructor */
	public TbOrder(TbAccount tbAccount, Timestamp orderdate,
			Short shippingmethodid, Short paymentmethodid, Double totalprice) {
		this.tbAccount = tbAccount;
		this.orderdate = orderdate;
		this.shippingmethodid = shippingmethodid;
		this.paymentmethodid = paymentmethodid;
		this.totalprice = totalprice;
	}

	/** full constructor */
	public TbOrder(TbAccount tbAccount, String receiveaddress,
			String receivephonenumber, Timestamp orderdate,
			String receivepersonname, Short shippingmethodid,
			Short paymentmethodid, Double totalprice,
			List<TbOrderDetail> tbOrderDetails) {
		this.tbAccount = tbAccount;
		this.receiveaddress = receiveaddress;
		this.receivephonenumber = receivephonenumber;
		this.orderdate = orderdate;
		this.receivepersonname = receivepersonname;
		this.shippingmethodid = shippingmethodid;
		this.paymentmethodid = paymentmethodid;
		this.totalprice = totalprice;
		this.tbOrderDetails = tbOrderDetails;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ORDERID", unique = true, nullable = false)
	public Long getOrderid() {
		return this.orderid;
	}

	public void setOrderid(Long orderid) {
		this.orderid = orderid;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "USERID", nullable = false)
	public TbAccount getTbAccount() {
		return this.tbAccount;
	}

	public void setTbAccount(TbAccount tbAccount) {
		this.tbAccount = tbAccount;
	}

		
	 @Column(name = "STATUS")
	public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Column(name = "RECEIVEADDRESS", length = 65535)
	public String getReceiveaddress() {
		return this.receiveaddress;
	}

	public void setReceiveaddress(String receiveaddress) {
		this.receiveaddress = receiveaddress;
	}

	@Column(name = "RECEIVEPHONENUMBER", length = 12)
	public String getReceivephonenumber() {
		return this.receivephonenumber;
	}

	public void setReceivephonenumber(String receivephonenumber) {
		this.receivephonenumber = receivephonenumber;
	}

	@Column(name = "ORDERDATE", nullable = false, length = 19)
	public Timestamp getOrderdate() {
		return this.orderdate;
	}

	public void setOrderdate(Timestamp orderdate) {
		this.orderdate = orderdate;
	}

	@Column(name = "RECEIVEPERSONNAME")
	public String getReceivepersonname() {
		return this.receivepersonname;
	}

	public void setReceivepersonname(String receivepersonname) {
		this.receivepersonname = receivepersonname;
	}

	@Column(name = "SHIPPINGMETHODID", nullable = false)
	public Short getShippingmethodid() {
		return this.shippingmethodid;
	}

	public void setShippingmethodid(Short shippingmethodid) {
		this.shippingmethodid = shippingmethodid;
	}

	@Column(name = "PAYMENTMETHODID", nullable = false)
	public Short getPaymentmethodid() {
		return this.paymentmethodid;
	}

	public void setPaymentmethodid(Short paymentmethodid) {
		this.paymentmethodid = paymentmethodid;
	}

	@Column(name = "TOTALPRICE", nullable = false, precision = 22, scale = 0)
	public Double getTotalprice() {
		return this.totalprice;
	}

	public void setTotalprice(Double totalprice) {
		this.totalprice = totalprice;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbOrder")
	public List<TbOrderDetail> getTbOrderDetails() {
		return this.tbOrderDetails;
	}

	public void setTbOrderDetails(List<TbOrderDetail> tbOrderDetails) {
		this.tbOrderDetails = tbOrderDetails;
	}

}